package util;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.List;

public class ControllerHelper {
    //获的代表查询条件的list对象
    public static List<Condition> getConditions(JSONObject req_jsonObj){
        //jsonObject转换为json数组
        JSONArray conditionList_jsonArray = req_jsonObj.getJSONArray("conditionList");
        //条件对象
        List<Condition> conditionList = null;
        //如果有"conditionList"键
        if (conditionList_jsonArray != null){
            //将描述条件的JSONArray 对象转换为java的list对象
            conditionList = conditionList_jsonArray.toJavaList(Condition.class);
        }
        return conditionList;
    }
    //获的代表查询条件的Pagination对象
    public static Pagination getPagination(JSONObject req_jsonObj){
        JSONObject pagination_jsonObj = req_jsonObj.getJSONObject("pagination");
        //定义pagination
        Pagination pagination = null;
        //如果有"pagination"键
        if (pagination_jsonObj != null){
            //将描述分页的JSONObject对象转换为java对象
            pagination = pagination_jsonObj.toJavaObject(Pagination.class);
        }
        return pagination;
    }
}
